<?php


namespace app\api\controller;


use app\api\service\ChartService;
use app\common\validate\ChartPersonalValidate;
use think\response\Json;

class ChartController extends ApiBaseController
{
    public function personalUpdate(ChartPersonalValidate $validate,ChartService $service): Json{

        $check = $validate->scene('api_info')->check($this->param);
        if (!$check) {
            return api_error($validate->getError());
        }

        try{

            $this->param['user_id'] = $this->user->id;
            $service->savePersonal($this->param);
            return api_success();
        }catch (\Exception $e){

            return api_error($e->getMessage());
        }
    }

    public function personalInfo(ChartService $service){
        try {

            $data = $service->getPersonalByUserId($this->user->id);
            return api_success($data);
        }catch (\Exception $e){

            return api_error($e->getMessage());
        }
    }
}